$(function () {
    $("#page_btn").click(function () {
        window.location.href = 'mime'
    });

    queryRecord(1);

    $("#nextPage").click(function () {
        console.log('next page')
        nextPage();
    });

    $("#prePage").click(function () {
        prePage();
    });

})

function nextPage() {
    var pageNum = parseInt($("#pageNumber").val())
    var pages = parseInt($("#pages").val());
    if (pageNum < pages) {
        queryRecord(pageNum + 1);
    } else {
        console.log("no next page")
    }
}

function prePage() {
    var pageNum = parseInt($("#pageNumber").val())
    var pages = parseInt($("#pages").val());
    if (pageNum > 1) {
        queryRecord(pageNum - 1);
    }
}

function queryRecord(page_num) {
    var data = {
        pageNum: page_num,
        pageSize: 10
    }

    $.ajax({
        type: "get",
        url: "../income/queryIncome",
        dataType: "json",
        contentType: "application/json",
        data: data,
        success: function (msg) {
            console.log(msg.data)
            var ll = msg.data.list;
            var res = "";
            for (var i = 0; i < ll.length; i++) {
                var d = ll[i];
                if (d.incomeType == '0') {
                    res += "<li data-v-f26d0378=\"\">\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\"><span style=\"color: green\">-₹" + d.amount + "</span></p>\n" +
                        "                            </ol>\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\">Place Order</p>\n" +
                        "                            </ol>\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\" class=\"oddnum\">" + d.createTime + "</p></ol>\n" +
                        "                    </li>"
                }else if (d.incomeType == '1'){
                    res += "<li data-v-f26d0378=\"\">\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\"><span style=\"color: red\">+₹" + d.amount + "</span></p>\n" +
                        "                            </ol>\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\">Win a prize</p>\n" +
                        "                            </ol>\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\" class=\"oddnum\">" + d.createTime + "</p></ol>\n" +
                        "                    </li>"
                }
                else if (d.incomeType == '2'){
                    res += "<li data-v-f26d0378=\"\">\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\"><span style=\"color: red\">+₹" + d.amount + "</span></p>\n" +
                        "                            </ol>\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\">Sign in</p>\n" +
                        "                            </ol>\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\" class=\"oddnum\">" + d.createTime + "</p></ol>\n" +
                        "                    </li>"
                }else if (d.incomeType == '3'){
                    res += "<li data-v-f26d0378=\"\">\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\"><span style=\"color: red\">+₹" + d.amount + "</span></p>\n" +
                        "                            </ol>\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\">Commission sharing</p>\n" +
                        "                            </ol>\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\" class=\"oddnum\">" + d.createTime + "</p></ol>\n" +
                        "                    </li>"
                }else if (d.incomeType == '4'){
                    res += "<li data-v-f26d0378=\"\">\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\"><span style=\"color: red\">+₹" + d.amount + "</span></p>\n" +
                        "                            </ol>\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\">sharing</p>\n" +
                        "                            </ol>\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\" class=\"oddnum\">" + d.createTime + "</p></ol>\n" +
                        "                    </li>"
                }else if (d.incomeType == '5'){
                    res += "<li data-v-f26d0378=\"\">\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\"><span style=\"color: red\">+₹" + d.amount + "</span></p>\n" +
                        "                            </ol>\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\">first recharge</p>\n" +
                        "                            </ol>\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\" class=\"oddnum\">" + d.createTime + "</p></ol>\n" +
                        "                    </li>"
                }else if (d.incomeType == '6'){
                    res += "<li data-v-f26d0378=\"\">\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\"><span style=\"color: red\">+₹" + d.amount + "</span></p>\n" +
                        "                            </ol>\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\">second recharge</p>\n" +
                        "                            </ol>\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\" class=\"oddnum\">" + d.createTime + "</p></ol>\n" +
                        "                    </li>"
                }else if (d.incomeType == '7'){
                    res += "<li data-v-f26d0378=\"\">\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\"><span style=\"color: red\">+₹" + d.amount + "</span></p>\n" +
                        "                            </ol>\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\">first share </p>\n" +
                        "                            </ol>\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\" class=\"oddnum\">" + d.createTime + "</p></ol>\n" +
                        "                    </li>"
                }else if (d.incomeType == '8'){
                    res += "<li data-v-f26d0378=\"\">\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\"><span style=\"color: red\">+₹" + d.amount + "</span></p>\n" +
                        "                            </ol>\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\">recharge amount</p>\n" +
                        "                            </ol>\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\" class=\"oddnum\">" + d.createTime + "</p></ol>\n" +
                        "                    </li>"
                } else if (d.incomeType == '9'){
                    res += "<li data-v-f26d0378=\"\">\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\"><span style=\"color: red\">+₹" + d.amount + "</span></p>\n" +
                        "                            </ol>\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\">Amount attached to registration</p>\n" +
                        "                            </ol>\n" +
                        "                        <ol data-v-f26d0378=\"\"><p data-v-f26d0378=\"\" class=\"oddnum\">" + d.createTime + "</p></ol>\n" +
                        "                    </li>"
                }
            }
            console.log(res)
            $("#completed_list").html(res);
            $("#pageNumber").val(msg.data.pageNum);
            $("#pages").val(msg.data.pages);
            $("#page_num").html(msg.data.pageNum);
            $("#currentPage").html(msg.data.pageNum);
        }
    })
}